#include <iostream>
#include <queue>
using namespace std;


struct G_Edge {
	int S, E;
	int C;
	G_Edge(int s, int e, int c): S(s), E(e), C(c) { }
};

operator < (G_Edge lhs, G_Edge rhs) {
	return (lhs.C > rhs.C);
}

int N, P;
int C[10005];

priority_queue<G_Edge> EDGE;
int FL[100005];

int input() {
	scanf("%d%d", &N, &P);
	int min_time = 0x7F7F7F7F;
	for (int i=1; i<=N; i++) {
		scanf("%d", &C[i]);
		if (C[i] < min_time) min_time = C[i];
	}
	for (int i=1; i<=N; i++) {
		FL[i] = i;
	}
	for (int i=1; i<=P; i++) {
		int S, E, L;
		scanf("%d%d%d", &S, &E, &L);
		G_Edge edge = G_Edge(S, E, 2*L + C[S] + C[E]);
		EDGE.push(edge);
	}
	return min_time;
}

int Kruskal() {
	int time = 0;
	int cnt = 0;
	while (!EDGE.empty()) {
		G_Edge edge = EDGE.top(); EDGE.pop();
		int s = edge.S;
		int e = edge.E;
		int fls = FL[s];
		int fle = FL[e];
		if (fls != fle) {
			time += edge.C;
			for (int i=1; i<=N; i++) {
				if (FL[i] == fle) FL[i]=fls;
			}
			cnt++;
			if (cnt >= N-1) break;
		}
	}
	return time;
}

int main() {
	int min_time = input();
	int t = Kruskal() + min_time;
	printf("%d", t);
}
